<template>
	<view class="ggitem">
		<my-adress></my-adress>
		<view v-if="cart.length !== 0">
			<view class="cart_title">
				<uni-icons type="shop" font-size="18"></uni-icons>
				<text class="cart_item_title">购物车</text>
			</view>
			
			<uni-swipe-action ref="gg">
				<block v-for="(item,index) in cart" :key="index">
					<uni-swipe-action-item  :right-options="options"  @click="swiperonClick(item)">
						<my-goods :shownum="shownum" @changenum="changenum" :item="item" @radio-click="radioclick"></my-goods>
					</uni-swipe-action-item>
				</block>
			</uni-swipe-action>
			<my-serct></my-serct>
		</view>
		
		<view class="kong" v-else>
			<image class="bg_img" src="../../static/cart_empty@2x.png"></image>
			<view class="bg_f">空空如也</view>
		</view>
	</view>
</template>
<script>
	import bdage from '@/mixins/tabbar-baage.js'
	import {mapState,mapMutations} from 'vuex'
	export default {
		mixins: [bdage],
		data () {
			return {
				shownum: true,
				options: [{
					text: '删除',
					style: {
						backgroundColor: '#C00000'
					}
				}]
			}
		},
		computed: {
			...mapState(['cart'])
		},
		methods: {
			...mapMutations(['ChangeRario','ChangeNumber','ChangeShop']),
			radioclick (e) {
				this.ChangeRario(e)
			},
			changenum (e) {
				this.ChangeNumber(e)
			},
			swiperonClick (item) {
				this.ChangeShop(item)
			}
		}
	}
</script>
<style lang="scss">
	.cart_title {
		height: 40px;
		display: flex;
		align-items: center;
		padding-left: 15px;
		border-bottom: 1px solid #EFEFEF;
		.cart_item_title {
			margin-left: 5px;
			font-size: 14px;
		}
	}
	.ggitem {
		width: 750rpx;
	}
	.ggitem {
		padding-bottom: 50px;
	}
	.kong {
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%,-50%);
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		.bg_img {
			width: 80px;
			height: 80px;
		}
	}
</style>